{% extends 'base.html.twig' %}
{% import 'Import/app_import.html.twig' as appImport %}

{% block head_title %}{{ 'index_templates_legacy'|trans }} - {{ template.name }}{% endblock %}

{% block heading_1 %}
    {{ appImport.heading({'level': 1, 'title': 'index_templates_legacy'|trans, 'link': {'url': path('index_templates_legacy')}}) }}
{% endblock %}

{% block heading_2 %}
    {{ appImport.heading({'level': 2, 'title': template.name}) }}
{% endblock %}

{% block tabs %}
    {% include 'Modules/index_template_legacy/index_template_legacy_read_tabs.html.twig' with {'active': 'summary'} %}
{% endblock %}

{% block main_content %}
    {% embed 'Embed/block_embed.html.twig' %}
        {% import 'Import/app_import.html.twig' as appImport %}
        {% block content %}
            {{ appImport.heading({'level': 3, 'title': 'summary'|trans}) }}

            {% embed 'Embed/buttons_embed.html.twig' %}
                {% import 'Import/app_import.html.twig' as appImport %}
                {% block content %}
                    {% if is_granted('INDEX_TEMPLATE_LEGACY_DELETE', template) %}
                        {{ appImport.buttonModal({
                            'id': 'IndexTemplateDelete',
                            'title': 'delete'|trans,
                            'body': template.name,
                            'href': path('index_templates_legacy_delete', {'name': template.name}),
                        }) }}
                    {% endif %}

                    {% if is_granted('INDEX_TEMPLATE_LEGACY_COPY', template) %}
                        <a class="btn btn-primary btn-sm" href="{{ path('index_templates_legacy_create', {'template': template.name}) }}">{{ 'copy'|trans }}</a>
                    {% endif %}
                {% endblock %}
            {% endembed %}

            {% if true == hasFeature('ilm') and template.setting('index.lifecycle.name') %}
                <p>
                    <strong>{{ 'ilm_policy'|trans }}</strong><br>
                    {% if is_granted('ILM_POLICIES_LIST', 'ilm_policy') %}
                        <a class="{{ theme_link_secondary }}" href="{{ path('ilm_read', {'name': template.setting('index.lifecycle.name')}) }}">{{ template.setting('index.lifecycle.name') }}</a>
                    {% else %}
                        {{ template.setting('index.lifecycle.name') }}
                    {% endif %}
                </p>
            {% endif %}

            <p>
                <strong>{{ 'index_patterns'|trans }}</strong><br>
                {{ template.indexPatterns|join(', ') }}
            </p>

            {% if template.version %}
                <p>
                    <strong>{{ 'version'|trans }}</strong><br>
                    {{ template.version }}
                </p>
            {% endif %}

            <p>
                <strong>{{ 'order'|trans }}</strong><br>
                {{ template.order }}
            </p>
        {% endblock %}
    {% endembed %}
{% endblock %}
